package com.tianji.learning.controller;


import com.tianji.api.dto.leanring.LearningLessonDTO;
import com.tianji.learning.domain.dto.LearningRecordFormDTO;
import com.tianji.learning.service.ILearningRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 学习记录表 前端控制器
 * </p>
 *
 * @author 陈彦祖
 * @since 2024-11-08
 */
@Api(tags = "我的学习记录接口")
@RestController
@RequestMapping("/learning-records")
@RequiredArgsConstructor
public class LearningRecordController {

    private final ILearningRecordService learningRecordService;

    /**1
     * 查询指定课程的学习记录
     * @param courseId
     * @return
     */
    @GetMapping("/course/{courseId}")
    @ApiOperation("查询指定课程的学习记录")
    public LearningLessonDTO queryLearningRecord(@PathVariable("courseId") Long courseId){
        return learningRecordService.queryLearningRecord(courseId);
    }

    /**2
     * 提交学习记录
     * @param form
     */
    @ApiOperation("提交学习记录")
    @PostMapping
    public void submitLearningRecord(@RequestBody LearningRecordFormDTO form){
        learningRecordService.submitLearningRecord(form);
    }
}
